
/**
 * 微信工具类
 * @author hejiacheng
 * @date 2021-12-3
 */

import storageUtil from './storageUtil'

 let wxUtil = {}

/**
 * 获取openid
 */
wxUtil.getOpenId = function() {
  console.log('获取openid')
  // 已经存储了
  let openid = storageUtil.getStorage("openId")
  if(openid){
    return openid
  }

  wx.cloud.callFunction({
    name:"getopenid",
    complete:res=>{
      console.log(res)
      console.log('云函数获取到的openid:',res.result.openid)
      openid = res.result.openid;
      storageUtil.setStorage("openId", openid)
    }
  })
  return openid

}

export default wxUtil